//
//  EFSDashLineView.m
//  EFSMobile
//
//  Created by Chuan on 12/2/15.
//  Copyright © 2015 Elephants Financial Service. All rights reserved.
//

#import "EFSDashLineView.h"

@implementation EFSDashLineView

-(void)drawRect:(CGRect)rect
{
    if (self.efs_dashLineColor == nil) {
        return [super drawRect:rect];
    }
    
    CGContextRef context = UIGraphicsGetCurrentContext();
    
    CGContextSaveGState(context);
    
    CGFloat lengths[2] = {self.efs_dashLength, self.efs_dashDistance};
    
    CGContextSetLineDash(context, 0, lengths, 2);
    
    CGFloat width = self.width, height = self.height;
    
    CGContextSetLineWidth(context, MAX(width, height));
    
    CGContextSetStrokeColorWithColor(context, self.efs_dashLineColor.CGColor);
    
    CGContextBeginPath(context);
    //起始点设置为(0,0):注意这是上下文对应区域中的相对坐标，
    CGContextMoveToPoint(context, 0, 0);
    //设置下一个坐标点
    CGContextAddLineToPoint(context, width, height);
    //连接上面定义的坐标点
    CGContextStrokePath(context);
    
    CGContextRestoreGState(context);
}

@end
